package com.orange.score.activity.entry;

import android.app.AlertDialog.Builder;
import android.app.Dialog;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.AbsListView;
import android.widget.AbsListView.OnScrollListener;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemClickListener;
import android.widget.Button;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.OnChildClickListener;
import android.widget.TextView;
import android.widget.Toast;
import com.orange.common.android.widget.PullToRefreshExpandableListView;
import com.orange.common.android.widget.PullToRefreshExpandableListView.OnRefreshListener;
import com.orange.common.android.widget.PullToRefreshListView;
import com.orange.common.android.widget.PullToRefreshListView.OnRefreshListener;
import com.orange.score.activity.common.CommonFootballActivity;
import com.orange.score.activity.league.SelectLeagueActivity;
import com.orange.score.activity.match.RealtimeMatchDetailActivity;
import com.orange.score.android.service.FollowMatchService;
import com.orange.score.app.ScoreApplication;
import com.orange.score.constants.ScoreType;
import com.orange.score.model.config.ConfigManager;
import com.orange.score.model.league.League;
import com.orange.score.model.league.LeagueManager;
import com.orange.score.model.match.FilterMatchStatusType;
import com.orange.score.model.match.FollowMatchManager;
import com.orange.score.model.match.Match;
import com.orange.score.model.match.MatchGroup;
import com.orange.score.model.match.MatchManager;
import com.orange.score.network.ResultCodeType;
import com.orange.score.service.LiveUpdateChangeCallBack;
import com.orange.score.service.MatchService;
import com.orange.score.service.MatchServiceCallBack;
import com.orange.score.service.UserService;
import com.orange.score.utils.ToastUtil;
import com.readystatesoftware.viewbadger.BadgeView;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.Timer;
import java.util.TimerTask;

public class RealtimeMatchActivity extends CommonFootballActivity
  implements MatchServiceCallBack, LiveUpdateChangeCallBack, FollowMatchCallBack
{
  protected static final int ACTION_SELECT_LEAGUE = 20120109;
  private static final long LOAD_ALL_MATCH_INTERVAL = 1800000L;
  private static final String TAG = "RealtimeMatchActivity";
  protected static final int UPDATE_LIST_VIEW;
  RealtimeMatchListAdapter adapter;
  BadgeView badge;
  private int currentSort;
  RealtimeMatchExpandableListAdapter expandableAdapter;
  PullToRefreshExpandableListView expandableListView;
  private int firstVisibleIndex;
  Button followButton;
  int followCount;
  FollowMatchManager followMatchManager;
  public boolean forceRefreshWhenResume;
  List<MatchGroup> groups;
  Intent intent;
  Date lastLoadAllMatchDate;
  LeagueManager leagueManager;
  PullToRefreshListView listView;
  MatchManager matchManager;
  MatchService matchService;
  TextView noMatchTextView;
  UpdateFollowMatchBroadcastReceiver receiver;
  boolean switchFilterScoreType;
  final Handler timerTaskHandler;
  final Handler updateFollowMatchHandler;
  Timer updateListViewTimer;
  private int visibleLastIndex = 0;

  public RealtimeMatchActivity()
  {
    this.firstVisibleIndex = 0;
    this.listView = null;
    this.intent = new Intent();
    this.expandableListView = null;
    this.expandableAdapter = null;
    this.currentSort = 0;
    this.followCount = 0;
    this.followMatchManager = null;
    this.forceRefreshWhenResume = false;
    this.switchFilterScoreType = true;
    this.lastLoadAllMatchDate = new Date();
    this.updateFollowMatchHandler = new Handler(this)
    {
      public void handleMessage()
      {
        Log.d("RealtimeMatchActivity", "updateFollowMatchHandler <handleMessage>");
        this.this$0.updateFollowCountBadge();
        if (this.this$0.matchManager.getFilterMatchStatus() == FilterMatchStatusType.FOLLOWED)
          RealtimeMatchActivity.access$0(this.this$0);
        super.handleMessage(paramMessage);
      }
    };
    this.timerTaskHandler = new Handler(this)
    {
      public void handleMessage()
      {
        switch (paramMessage.what)
        {
        default:
        case 0:
        }
        while (true)
        {
          super.handleMessage(paramMessage);
          return;
          this.this$0.adapter.notifyDataSetChanged();
          this.this$0.expandableAdapter.notifyDataSetChanged();
        }
      }
    };
    this.groups = new ArrayList();
    this.receiver = new UpdateFollowMatchBroadcastReceiver(this);
  }

  private int buttonIndexFromScoreType(ScoreType paramScoreType)
  {
    int i;
    switch ($SWITCH_TABLE$com$orange$score$constants$ScoreType()[paramScoreType.ordinal()])
    {
    default:
      i = 0;
    case 2:
    case 1:
    case 3:
    case 4:
    case 5:
    }
    while (true)
    {
      while (true)
      {
        while (true)
        {
          while (true)
          {
            while (true)
            {
              return i;
              i = 0;
            }
            i = 1;
          }
          i = 2;
        }
        i = 3;
      }
      i = 4;
    }
  }

  private ScoreType buttonIndexToScoreType(int paramInt)
  {
    ScoreType localScoreType;
    switch (paramInt)
    {
    default:
      localScoreType = ScoreType.FIRST;
    case 1:
    case 2:
    case 3:
    case 4:
    }
    while (true)
    {
      while (true)
      {
        while (true)
        {
          while (true)
          {
            return localScoreType;
            localScoreType = ScoreType.ALL;
          }
          localScoreType = ScoreType.ZUCAI;
        }
        localScoreType = ScoreType.JINGCAI;
      }
      localScoreType = ScoreType.DANCHANGE;
    }
  }

  private List<MatchGroup> composeListToGroup(List<Match> paramList)
  {
    Iterator localIterator2;
    HashMap localHashMap = new HashMap();
    Iterator localIterator1 = paramList.iterator();
    if (!(localIterator1.hasNext()))
    {
      this.groups.clear();
      List localList1 = this.leagueManager.findAllLeagues();
      if ((localList1 != null) && (localList1.size() > 0))
        localIterator2 = localList1.iterator();
    }
    while (true)
    {
      Map.Entry localEntry;
      if (!(localIterator2.hasNext()))
      {
        return this.groups;
        Match localMatch = (Match)localIterator1.next();
        String str = localMatch.getLeagueId();
        Object localObject = (List)localHashMap.get(str);
        if ((localObject == null) || (((List)localObject).size() == 0))
        {
          localObject = new ArrayList();
          ((List)localObject).add(localMatch);
        }
        while (true)
        {
          while (true)
            localHashMap.put(str, localObject);
          ((List)localObject).add(localMatch);
        }
      }
      League localLeague = (League)localIterator2.next();
      Iterator localIterator3 = localHashMap.entrySet().iterator();
      do
      {
        if (!(localIterator3.hasNext()));
        localEntry = (Map.Entry)localIterator3.next();
      }
      while (!(((String)localEntry.getKey()).equals(localLeague.getLeagueId())));
      List localList2 = (List)localEntry.getValue();
      MatchGroup localMatchGroup = new MatchGroup(localLeague.getLeagueName(), localList2);
      this.groups.add(localMatchGroup);
    }
  }

  private void decrementFollow()
  {
    if (this.followCount > 0)
      this.followCount -= 1;
    if (this.followCount > 0)
    {
      this.badge.setText(this.followCount);
      this.badge.show();
    }
    while (true)
    {
      return;
      this.badge.hide();
    }
  }

  private LeagueManager getLeagueManager()
  {
    return getMatchService().getLeagueManager();
  }

  private MatchManager getMatchManager()
  {
    return getMatchService().getMatchManager();
  }

  private MatchService getMatchService()
  {
    return ((ScoreApplication)getApplication()).getRealtimeMatchService();
  }

  private String getScoreTypeString(ScoreType paramScoreType)
  {
    String str;
    switch ($SWITCH_TABLE$com$orange$score$constants$ScoreType()[paramScoreType.ordinal()])
    {
    case 2:
    default:
      str = getResources().getString(2131361830);
    case 1:
    case 4:
    case 5:
    case 3:
    }
    while (true)
    {
      while (true)
      {
        while (true)
        {
          while (true)
          {
            return str;
            str = getResources().getString(2131361831);
          }
          str = getResources().getString(2131361834);
        }
        str = getResources().getString(2131361832);
      }
      str = getResources().getString(2131361833);
    }
  }

  private void incrementFollow()
  {
    this.followCount = (1 + this.followCount);
    this.badge.setText(this.followCount);
    this.badge.show();
  }

  private void initExpandableListView()
  {
    this.expandableListView = ((PullToRefreshExpandableListView)findViewById(2131558563));
    this.expandableListView.setFastScrollEnabled(true);
    initializeExpandableAdapter();
    this.expandableListView.setAdapter(this.expandableAdapter);
    this.expandableListView.setOnChildClickListener(new ExpandableListView.OnChildClickListener(this)
    {
      public boolean onChildClick(, View paramView, int paramInt1, int paramInt2, long paramLong)
      {
        Match localMatch = (Match)((MatchGroup)this.this$0.groups.get(paramInt1)).children.get(paramInt2);
        if (localMatch == null)
          Log.e("RealtimeMatchActivity", "RealtimeMatch expandableListView get match at groupPosition " + paramInt1 + " childPosition " + paramInt2 + " null");
        while (true)
        {
          return false;
          this.this$0.intent.setClass(this.this$0, RealtimeMatchDetailActivity.class);
          this.this$0.intent.setFlags(131072);
          Bundle localBundle = new Bundle();
          String str = localMatch.getMatchId();
          Log.d("RealtimeMatchActivity", "matchId: " + localMatch.getMatchId());
          localBundle.putString("matchId", str);
          this.this$0.intent.putExtras(localBundle);
          this.this$0.startActivity(this.this$0.intent);
        }
      }
    });
    this.expandableListView.setOnRefreshListener(new PullToRefreshExpandableListView.OnRefreshListener(this)
    {
      public void onRefresh()
      {
        this.this$0.refreshCurrentMatchList();
      }
    });
  }

  private void initListView()
  {
    this.listView = ((PullToRefreshListView)findViewById(2131558562));
    this.listView.setFastScrollEnabled(true);
    initializeAdapter();
    this.listView.setAdapter(this.adapter);
    this.listView.setOnRefreshListener(new PullToRefreshListView.OnRefreshListener(this)
    {
      public void onRefresh()
      {
        this.this$0.refreshCurrentMatchList();
      }
    });
    this.listView.setOnItemClickListener(new AdapterView.OnItemClickListener(this)
    {
      public void onItemClick(, View paramView, int paramInt, long paramLong)
      {
        Match localMatch = (Match)this.this$0.adapter.getItem(paramInt - 1);
        if (localMatch == null)
          Log.e("RealtimeMatchActivity", "RealtimeMatch adapter get match at position " + paramInt + " null");
        while (true)
        {
          return;
          this.this$0.intent.setClass(this.this$0, RealtimeMatchDetailActivity.class);
          this.this$0.intent.setFlags(131072);
          Bundle localBundle = new Bundle();
          String str = localMatch.getMatchId();
          Log.d("RealtimeMatchActivity", "matchId: " + localMatch.getMatchId());
          localBundle.putString("matchId", str);
          this.this$0.intent.putExtras(localBundle);
          this.this$0.startActivity(this.this$0.intent);
        }
      }
    });
    this.listView.setOnScrollListener(new AbsListView.OnScrollListener(this)
    {
      public void onScroll(, int paramInt1, int paramInt2, int paramInt3)
      {
        RealtimeMatchActivity.access$1(this.this$0, paramInt1 + paramInt2);
        if ((this.this$0.adapter.getCount() == RealtimeMatchActivity.access$2(this.this$0) - 1) && (this.this$0.adapter.nextPage()))
          this.this$0.adapter.notifyDataSetChanged();
      }

      public void onScrollStateChanged(, int paramInt)
      {
      }
    });
  }

  private void initScoreTypeButton()
  {
    Button localButton = (Button)findViewById(2131558514);
    updateScoreTypeButton();
    localButton.setOnClickListener(new View.OnClickListener(this)
    {
      public void onClick()
      {
        int i = RealtimeMatchActivity.access$6(this.this$0, this.this$0.matchManager.getFilterScoreType());
        Log.d("RealtimeMatchActivity", "current index = " + i);
        new AlertDialog.Builder(this.this$0).setTitle(2131361818).setSingleChoiceItems(2131165185, i, new DialogInterface.OnClickListener(this)
        {
          public void onClick(, int paramInt)
          {
            Log.d("RealtimeMatchActivity", "click " + paramInt);
            paramDialogInterface.dismiss();
            ScoreType localScoreType = RealtimeMatchActivity.access$7(RealtimeMatchActivity.11.access$0(this.this$1), paramInt);
            if ((localScoreType != RealtimeMatchActivity.11.access$0(this.this$1).matchManager.getFilterScoreType()) || (RealtimeMatchActivity.access$8(RealtimeMatchActivity.11.access$0(this.this$1))))
            {
              RealtimeMatchActivity.11.access$0(this.this$1).switchFilterScoreType = true;
              RealtimeMatchActivity.11.access$0(this.this$1).matchManager.setFilterScoreType(localScoreType);
              RealtimeMatchActivity.access$9(RealtimeMatchActivity.11.access$0(this.this$1));
              RealtimeMatchActivity.access$10(RealtimeMatchActivity.11.access$0(this.this$1));
              RealtimeMatchActivity.11.access$0(this.this$1).updateFollowCountBadge();
            }
            while (true)
            {
              return;
              RealtimeMatchActivity.11.access$0(this.this$1).switchFilterScoreType = false;
            }
          }
        }).setNegativeButton(2131361823, new DialogInterface.OnClickListener(this)
        {
          public void onClick(, int paramInt)
          {
            Log.d("RealtimeMatchActivity", "click cancel");
          }
        }).create().show();
      }
    });
  }

  private void initSelectLeagueButton()
  {
    ((Button)findViewById(2131558516)).setOnClickListener(new View.OnClickListener(this)
    {
      public void onClick()
      {
        Intent localIntent = new Intent();
        localIntent.setClass(this.this$0, SelectLeagueActivity.class);
        Bundle localBundle = new Bundle();
        localBundle.putInt("league_from", 1);
        ArrayList localArrayList = new ArrayList();
        localArrayList.addAll(this.this$0.matchManager.getFilterLeagueSet());
        localBundle.putStringArrayList("selected_league", localArrayList);
        localIntent.putExtras(localBundle);
        this.this$0.startActivityForResult(localIntent, 20120109);
      }
    });
  }

  private void initServicesAndManagers()
  {
    this.matchService = getMatchService();
    this.matchManager = getMatchManager();
    this.leagueManager = getLeagueManager();
  }

  private void initSortLeagueButton()
  {
    this.expandableListView.onRefreshComplete();
    ((Button)findViewById(2131558555)).setOnClickListener(new View.OnClickListener(this)
    {
      public void onClick()
      {
        new AlertDialog.Builder(this.this$0).setTitle(2131361819).setSingleChoiceItems(2131165186, RealtimeMatchActivity.access$4(this.this$0), new DialogInterface.OnClickListener(this)
        {
          public void onClick(, int paramInt)
          {
            Log.d("RealtimeMatchActivity", "click " + paramInt);
            paramDialogInterface.dismiss();
            RealtimeMatchActivity.access$5(RealtimeMatchActivity.10.access$0(this.this$1), paramInt);
            switch (paramInt)
            {
            default:
            case 0:
            case 1:
            }
            while (true)
            {
              while (true)
              {
                return;
                RealtimeMatchActivity.10.access$0(this.this$1).listView.setVisibility(0);
                RealtimeMatchActivity.10.access$0(this.this$1).expandableListView.setVisibility(8);
              }
              RealtimeMatchActivity.10.access$0(this.this$1).listView.setVisibility(8);
              RealtimeMatchActivity.10.access$0(this.this$1).expandableListView.setVisibility(0);
            }
          }
        }).setNegativeButton(2131361823, new DialogInterface.OnClickListener(this)
        {
          public void onClick(, int paramInt)
          {
            Log.d("RealtimeMatchActivity", "click cancel");
          }
        }).create().show();
      }
    });
  }

  private void initializeAdapter()
  {
    this.adapter = new RealtimeMatchListAdapter(this.matchManager.filterMatch(), this, this);
  }

  private void initializeExpandableAdapter()
  {
    this.groups = composeListToGroup(this.matchManager.filterMatch());
    this.expandableAdapter = new RealtimeMatchExpandableListAdapter(this.groups, this, this);
  }

  private boolean isDataTooOld()
  {
    int i;
    if (new Date().getTime() - this.lastLoadAllMatchDate.getTime() > 1800000L)
      i = 1;
    while (true)
    {
      return i;
      i = 0;
    }
  }

  private void loadAllMatch()
  {
    this.matchService.loadAllMatch(this, this);
  }

  private void reloadListDataAndView()
  {
    stopUpdateListViewTimer();
    updateMatchContentList();
    startUpdateListViewTimer();
  }

  private void setMatchFilterButtonClickListener(int paramInt, FilterMatchStatusType paramFilterMatchStatusType)
  {
    this.listView.onRefreshComplete();
    ((Button)findViewById(paramInt)).setOnClickListener(new View.OnClickListener(this, paramInt, paramFilterMatchStatusType)
    {
      public void onClick()
      {
        if (this.val$buttonId == 2131558561)
        {
          this.this$0.listView.supportRefreshHeader = false;
          this.this$0.matchManager.setFilterMatchStatus(this.val$status);
          RealtimeMatchActivity.access$12(this.this$0);
          if (!(RealtimeMatchActivity.access$8(this.this$0)))
            break label73;
          RealtimeMatchActivity.access$9(this.this$0);
        }
        while (true)
        {
          while (true)
          {
            return;
            this.this$0.listView.supportRefreshHeader = true;
          }
          label73: RealtimeMatchActivity.access$0(this.this$0);
        }
      }
    });
  }

  private void startUpdateListViewTimer()
  {
    if (this.updateListViewTimer != null)
    {
      this.updateListViewTimer.cancel();
      this.updateListViewTimer = null;
    }
    this.updateListViewTimer = new Timer();
    this.updateListViewTimer.schedule(new TimerTask(this)
    {
      public void run()
      {
        Log.d("RealtimeMatchActivity", " fire list view update timer");
        Message localMessage = new Message();
        localMessage.what = 0;
        this.this$0.timerTaskHandler.sendMessage(localMessage);
      }
    }
    , 0L, 1000L);
  }

  private void stopUpdateListViewTimer()
  {
    if (this.updateListViewTimer != null)
    {
      this.updateListViewTimer.cancel();
      this.updateListViewTimer = null;
    }
  }

  private void updateMatchContentList()
  {
    updateMatchContentList(this.matchManager.filterMatch());
  }

  private void updateMatchContentList(List<Match> paramList)
  {
    int i;
    int j;
    Iterator localIterator;
    ArrayList localArrayList = new ArrayList();
    if (paramList != null)
    {
      localIterator = paramList.iterator();
      if (localIterator.hasNext())
        break label111;
    }
    if (localArrayList.size() > 0)
    {
      this.noMatchTextView.setVisibility(4);
      this.adapter.updateList(localArrayList);
      this.groups = composeListToGroup(localArrayList);
      this.expandableAdapter.updateList(this.groups);
      this.expandableAdapter.notifyDataSetChanged();
      i = this.expandableAdapter.getGroupCount();
      if ((this.groups != null) && (i > 0))
        j = 0;
    }
    while (true)
    {
      while (true)
      {
        while (true)
        {
          if (j < i)
            break label142;
          return;
          label111: localArrayList.add((Match)localIterator.next());
        }
        this.noMatchTextView.setVisibility(0);
      }
      label142: this.expandableListView.expandGroup(j);
      ++j;
    }
  }

  private void updateMatchFilterButton()
  {
    int[] arrayOfInt;
    int j;
    int i = 2131558557;
    FilterMatchStatusType localFilterMatchStatusType = this.matchManager.getFilterMatchStatus();
    switch ($SWITCH_TABLE$com$orange$score$model$match$FilterMatchStatusType()[localFilterMatchStatusType.ordinal()])
    {
    default:
    case 1:
    case 2:
    case 3:
    case 4:
    case 5:
    }
    while (true)
    {
      while (true)
      {
        while (true)
        {
          while (true)
          {
            while (true)
            {
              arrayOfInt = new int[5];
              arrayOfInt[0] = 2131558557;
              arrayOfInt[1] = 2131558558;
              arrayOfInt[2] = 2131558559;
              arrayOfInt[3] = 2131558560;
              arrayOfInt[4] = 2131558561;
              j = 0;
              if (j < arrayOfInt.length)
                break label136;
              return;
              i = 2131558557;
            }
            i = 2131558558;
          }
          i = 2131558559;
        }
        i = 2131558560;
      }
      i = 2131558561;
    }
    label136: Button localButton = (Button)findViewById(arrayOfInt[j]);
    if (arrayOfInt[j] == i)
      localButton.setSelected(true);
    while (true)
    {
      while (true)
        ++j;
      localButton.setSelected(false);
    }
  }

  private void updateScoreTypeButton()
  {
    ((Button)findViewById(2131558514)).setText(getScoreTypeString(this.matchManager.getFilterScoreType()));
  }

  public void followUnfollowMatch(Match paramMatch)
  {
    if (this.followMatchManager == null)
      this.followMatchManager = FollowMatchService.getFollowMatchManager();
    if (paramMatch.isFollow())
    {
      this.followMatchManager.unfollowMatch(paramMatch);
      ToastUtil.showMessage(this, getResources().getString(2131361836));
    }
    while (true)
    {
      updateFollowCountBadge();
      if (this.matchManager.getFilterMatchStatus() == FilterMatchStatusType.FOLLOWED)
        reloadListDataAndView();
      return;
      this.followMatchManager.followMatch(paramMatch);
      ToastUtil.showMessage(this, getResources().getString(2131361835));
    }
  }

  public Handler getUpdateFollowMatchHandler()
  {
    return this.updateFollowMatchHandler;
  }

  public void loadAllMatchFinish(ResultCodeType paramResultCodeType)
  {
    switch ($SWITCH_TABLE$com$orange$score$network$ResultCodeType()[paramResultCodeType.ordinal()])
    {
    default:
      this.listView.onRefreshComplete();
    case 1:
    }
    while (true)
    {
      return;
      if ((this.switchFilterScoreType) || (this.matchManager.getFilterLeagueSet().isEmpty()))
        this.matchManager.selectAllLeagues(this.matchService.getLeagueManager().findAllLeagues());
      reloadListDataAndView();
      this.listView.onRefreshComplete();
      this.lastLoadAllMatchDate = new Date();
    }
  }

  public void loadMatchDetailFinish(ResultCodeType paramResultCodeType)
  {
  }

  public void notifyScoreLiveUpdate(List<String[]> paramList)
  {
    Log.d("RealtimeMatchActivity", "notifyScoreLiveUpdate");
    if ((paramList == null) || (paramList.size() == 0));
    while (true)
    {
      return;
      reloadListDataAndView();
    }
  }

  protected void onActivityResult(int paramInt1, int paramInt2, Intent paramIntent)
  {
    Log.d("RealtimeMatchActivity", "onActivityResult");
    super.onActivityResult(paramInt1, paramInt2, paramIntent);
    if (paramInt1 == 20120109)
    {
      if (paramIntent != null)
        break label36;
      Log.d("RealtimeMatchActivity", "onActivityResult but data is null");
    }
    while (true)
    {
      label36: ArrayList localArrayList;
      while (true)
      {
        return;
        localArrayList = paramIntent.getStringArrayListExtra("selected_league");
        if (localArrayList != null)
          break;
        Log.d("RealtimeMatchActivity", "onActivityResult but select league list is null");
      }
      Log.d("RealtimeMatchActivity", "onActivityResult, select league list is " + localArrayList);
      this.matchManager.selectLeagues(localArrayList);
      reloadListDataAndView();
    }
  }

  public void onBackPressed()
  {
    RealtimeMatchDetailActivity.EXIT_APPLICATION = true;
    finish();
  }

  public void onCreate(Bundle paramBundle)
  {
    registerReceiver();
    ScoreApplication.setRealtimeMatchActivity(this);
    super.onCreate(paramBundle);
    setContentView(2130903088);
    initServicesAndManagers();
    initListView();
    initExpandableListView();
    this.noMatchTextView = ((TextView)findViewById(2131558513));
    this.noMatchTextView.setVisibility(4);
    this.followButton = ((Button)findViewById(2131558561));
    this.badge = new BadgeView(this, this.followButton);
    this.badge.setBadgeMargin(0, 0);
    this.badge.setTextSize(10.0F);
    initScoreTypeButton();
    initSelectLeagueButton();
    initSortLeagueButton();
    setMatchFilterButtonClickListener(2131558557, FilterMatchStatusType.ALL);
    setMatchFilterButtonClickListener(2131558558, FilterMatchStatusType.NOT_STARTED);
    setMatchFilterButtonClickListener(2131558559, FilterMatchStatusType.ONGOING);
    setMatchFilterButtonClickListener(2131558560, FilterMatchStatusType.FINISH);
    setMatchFilterButtonClickListener(2131558561, FilterMatchStatusType.FOLLOWED);
    updateMatchFilterButton();
    this.matchService.addScoreLiveUpdateObserver(this);
    loadAllMatch();
    if (ConfigManager.getInstance().getIsFirstUsage())
    {
      Toast.makeText(this, "温馨提示：比分&指数即时更新数据流量较大，建议在wifi下使用本应用。", 1).show();
      ConfigManager.getInstance().setIsFirstUsage();
    }
    if (!(ScoreApplication.hasDetectUpdate()))
    {
      new UserService().updateClientWhenLaunch(this, "http://bf.bet007.com/phone/android_ver.txt", "http://bf.bet007.com/phone/down/Android");
      ScoreApplication.setDetectUpdate();
    }
  }

  public void onDestroy()
  {
    unregisterReceiver(this.receiver);
    Log.d("RealtimeMatchActivity", "onDestroy");
    this.matchService.removeScoreLiveUpdateObserver(this);
    stopUpdateListViewTimer();
    ScoreApplication.setRealtimeMatchActivity(null);
    super.onDestroy();
  }

  protected void onPause()
  {
    super.onPause();
    ScoreApplication.currentActivity = null;
    Log.d("RealtimeMatchActivity", "unregister follow match broadcast receiver");
    stopUpdateListViewTimer();
  }

  public void onRefresh()
  {
    refreshCurrentMatchList();
  }

  protected void onResume()
  {
    super.onResume();
    ScoreApplication.currentActivity = this;
    RealtimeMatchDetailActivity.EXIT_APPLICATION = false;
    this.listView.onRefreshComplete();
    if ((isDataTooOld()) || (this.forceRefreshWhenResume))
    {
      Log.d("RealtimeMatchActivity", "match data too old, reload all match data");
      loadAllMatch();
      this.forceRefreshWhenResume = false;
    }
  }

  public void refreshCurrentMatchList()
  {
    this.switchFilterScoreType = false;
    loadAllMatch();
  }

  public void registerReceiver()
  {
    Log.d("RealtimeMatchActivity", "register follow match broadcast receiver");
    IntentFilter localIntentFilter = new IntentFilter("FOLLOW_MATCH_BROADCAST");
    registerReceiver(this.receiver, localIntentFilter);
  }

  public void updateFollowCountBadge()
  {
    if (this.followMatchManager == null)
      this.followMatchManager = FollowMatchService.getFollowMatchManager();
    int i = this.followMatchManager.getFollowMatchList().size();
    Log.d("RealtimeMatchActivity", "<updateFollowCountBadge> count is " + i);
    if (i > 0)
    {
      this.badge.setText(String.valueOf(i));
      this.badge.show();
    }
    while (true)
    {
      return;
      this.badge.hide();
    }
  }

  public class UpdateFollowMatchBroadcastReceiver extends BroadcastReceiver
  {
    public void onReceive(, Intent paramIntent)
    {
      Log.d("RealtimeMatchActivity", "follow match broadcast message received");
      this.this$0.updateFollowCountBadge();
      if (this.this$0.matchManager.getFilterMatchStatus() == FilterMatchStatusType.FOLLOWED)
        RealtimeMatchActivity.access$0(this.this$0);
    }
  }
}